//
//  BK_SPF_Action_Cell.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/4/6.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_SPF_Action_Cell.h"
#import <Masonry.h>
#import "BK_OD_Color.h"

@interface BK_SPF_Action_Cell ()

@property (nonatomic,strong) UIButton* btn_Dismiss;
@property(nonatomic, strong) UIButton *btn_Again;//
@end



@implementation BK_SPF_Action_Cell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        self.backgroundColor = [UIColor clearColor];
        [self initView];
    }
    return self;
}

- (void)initView{
    _btn_Dismiss=[[UIButton alloc]init];
    _btn_Dismiss.backgroundColor=[UIColor clearColor];
    [_btn_Dismiss.layer setCornerRadius:5.0]; //设置矩形圆角半径
    [_btn_Dismiss.layer setBorderWidth:1.0]; //边框宽度
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 0.f/255.f,186.f/255.f,156.f/255.f , 1 });
    [_btn_Dismiss.layer setBorderColor:colorref];//边框颜色
    [_btn_Dismiss setTitle:@"放弃支付" forState:UIControlStateNormal];//button title
    [_btn_Dismiss setTitleColor:kOrderBKGreen forState:UIControlStateNormal];//title color
    [self addSubview:_btn_Dismiss];
    [_btn_Dismiss addTarget:self action:@selector(Action_Cancle) forControlEvents:UIControlEventTouchUpInside];
    [_btn_Dismiss mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.mas_centerY);
        make.left.mas_equalTo(self.mas_left).offset(ApplicationBackGauge);
        make.width.mas_equalTo(@((ScreenWidth-2*ApplicationBackGauge-14)/2.0));
        make.height.mas_equalTo(@(40));
    }];
    
    _btn_Again=[[UIButton alloc]init];
    _btn_Again.backgroundColor=kOrderBKGreen;
    [_btn_Again.layer setCornerRadius:5.0]; //设置矩形圆角半径
    [_btn_Again.layer setBorderWidth:1.0]; //边框宽度
    CGColorSpaceRef colorSpace1 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref1 = CGColorCreate(colorSpace1,(CGFloat[]){ 0.f/255.f,186.f/255.f,156.f/255.f , 1 });
    [_btn_Again.layer setBorderColor:colorref1];//边框颜色
    [_btn_Again addTarget:self action:@selector(Action_Again) forControlEvents:UIControlEventTouchUpInside];
    [_btn_Again setTitle:@"再试一次" forState:UIControlStateNormal];//button title
    [_btn_Again setTitleColor:kOrderWhite forState:UIControlStateNormal];//title color
    [self addSubview:_btn_Again];
    [_btn_Again mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.mas_centerY);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge);
        make.width.mas_equalTo((ScreenWidth-2*ApplicationBackGauge-14)/2.0);
        make.height.mas_equalTo(@(40));
    }];
    
    
}
/*
 * 放弃支付
 */
-(void)Action_Cancle{
    
    
    if ([self.delegate respondsToSelector:@selector(BK_SPF_Action_Cancle)]) {
        [self.delegate BK_SPF_Action_Cancle];
    }
}

/*
 * 再试一次
 */
-(void)Action_Again{
    if ([self.delegate respondsToSelector:@selector(BK_SPF_Action_Again)]) {
        [self.delegate BK_SPF_Action_Again];
    }
}

+(CGFloat)computeHeight:(id)data{
    return 60;
}



- (void)awakeFromNib {
    [super awakeFromNib];

    
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
